<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="validausuario.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Cambiar Password</title>
<LINK REL="stylesheet" TYPE="text/css" HREF="main.css">
<link rel="Shortcut Icon" href="icono_tm.ico" type="image/x-icon" />
<script src="prototype.js" language="JavaScript"></script>
<script language="javascript">

function changepassword(usuario) {
	var clave = $F("clave");
	var clave2 = $F("re_clave");
	
	if (clave != clave2) {
		alert("Las claves ingresadas son diferentes");
		return
	}
	
	var url = "SrvUsuarios?operacion=changepassword&usuario="+encodeURIComponent(usuario) + "&clave=" + encodeURIComponent(clave);
	new Ajax.Request(url,{
		method: 'POST',
		onComplete: procesar 
	});
}
function procesar(transport) {
	var resultado = transport.responseText;
	if (resultado != 'OK') {
		document.getElementById("info").innerHTML = resultado;
	}else {
		alert("Clave cambiada correctamente");
		window.location.href = "menu.jsp?menu=1";
	}
}
</script>
</head>
<body>
<%@ include file="header.jsp"%>
<h2>Cambiar Password</h2>
<div id="info" class="warning"></div>
<form action="" method="POST">
	<table>
		<tr>
			<th colspan=2>Datos de Usuario</th>
		</tr>
		<tr>
			<td>Usuario</td>
			<td><%= (String)session.getAttribute("usuario") %></td>
		</tr>
		<tr>
		<td>Nueva Clave</td>
		<td><input type="password" id="clave" name="clave"> 
		</td>
	</tr>
	<tr>
		<td>Repetir Clave</td>
		<td><input type="password" id="re_clave" name="re_clave"> </td>
	</tr>
	<tr>
		<td colspan=2><a href="javascript:changepassword('<%= (String)session.getAttribute("usuario") %>');" class="small button blue">Cambiar</a></td>
	</tr>
	</table>

</form>

<%@ include file="foot.jsp"%>
</body>
</html>